import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    user: "",
    username: "",
    latest: 0,
    like: 0,
    userobj: {},
  },
  mutations: {
    userid: (state, user) => {
      state.user = user;
    },
    username: (state, data) => {
      state.username = data;
    },
    latest: (state, data) => {
      state.latest = data;
    },
    like: (state, data) => {
      state.like = data;
    },
    userobj: (state, data) => {
      state.userobj = data;
    },
    // addAccount: (state, a) => {
    //   const index = state.accounts.findIndex((e) => e.name === a.name);
    //   if (index > -1) {
    //     state.accounts.splice(index, 1, a);
    //   } else {
    //     state.accounts.push(a);
    //   }
    // },
    // removeAccount: (state, name) => {
    //   const index = state.accounts.findIndex((e) => e.name === name);
    //   index > -1 && state.accounts.splice(index, 1);
    // },
  },
  actions: {},
  modules: {},
});
